package com.zhu.websocketdemo.repository;

import com.zhu.websocketdemo.pojo.PrivateMessage;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PrivateMassageRepository extends PagingAndSortingRepository<PrivateMessage, Integer> {
    @Query("select p from PrivateMessage p where p.fromUser = ?1")
    List<PrivateMessage> findByFromUser(String fromUser);

    @Query("select p from PrivateMessage p where p.toUser = ?1")
    List<PrivateMessage> findByToUser(String toUser);
}
